package com.atguigu.yygh.hosp.controller.admin;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "医院科室排班后端的接口")
@RestController
@RequestMapping("/admin/hosp/schedule")
//@CrossOrigin
public class AdminScheduleController {
    @Autowired
    private ScheduleService scheduleService;

    /**
     * todo:排班日期分页列表
     * --->>>根据医院编号 和 科室编号 ，查询排班规则数据
     * Map<String, Object> getRuleSchedule(long page, long limit, String hoscode, String depcode);
     *
     * @return
     */
    @ApiOperation("排班日期分页列表")
    @GetMapping("/getRuleSchedule/{page}/{limit}/{hoscode}/{depcode}")
    public Result findScheduleBy(@PathVariable("page") long page,
                                 @PathVariable("limit") long limit,
                                 @PathVariable("hoscode")  String hoscode,
                                 @PathVariable("depcode")  String depcode
    ) {
      Map<String,Object> resMap = scheduleService.getRuleScheduleByHoscodeAndDepcode(page,limit,hoscode,depcode);

        return Result.ok(resMap);
    }

    //根据医院编号 、科室编号和工作日期，查询排班详细信息
    @ApiOperation(value = "查询排班详细信息")
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail( @PathVariable String hoscode,
                                     @PathVariable String depcode,
                                     @PathVariable String workDate) {
        List<Schedule> list = scheduleService.getDetailSchedule(hoscode,depcode,workDate);
        return Result.ok(list);
    }

}
